package virtualstock.entity;

import java.io.Serializable;
import java.util.Collection;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

@Entity
@Table(name = "player", schema = "vstock")
@NamedQueries({
	@NamedQuery(name="Player.FindByEmail", query = "SELECT a FROM Player a WHERE a.email = :email"),
	@NamedQuery(name="Player.FindAllPlayer", query= "SELECT a FROM Player a")
})
public class Player implements Serializable {
	@Id
	@Column(name="playerID")
	private Long playerID;

	@Column(name="email")
	private String email;

	@Column(name="first_name")
	private String firstName;

	@Column(name="last_name")
	private String lastName;

	@Column(name="password")
	private String password;
	
	@ManyToMany(mappedBy = "players", fetch = FetchType.EAGER)
	private Collection<Game> games;

	private static final long serialVersionUID = 1L;

	public Player() {
		super();
	}
	
	public Player(String email, String password, String firstName, String lastName) {
		this.email = email;
		this.password = password;
		this.firstName = firstName;
		this.lastName = lastName;
	}

	public Long getPlayerID() {
		return this.playerID;
	}

	public void setPlayerID(Long playerID) {
		this.playerID = playerID;
	}

	public String getEmail() {
		return this.email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getFirstName() {
		return this.firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return this.lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public void setGames(Collection<Game> games) {
		this.games = games;
	}

	public Collection<Game> getGames() {
		return games;
	}

}
